<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title><% model(2); %></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="config.js"></script>
<script type="text/javascript" src="general.js"></script>
<script type="text/javascript" src="quick.js"></script>
<script type="text/javascript">
	var sCDMA	= "C";
	var sGPRS	= "W";
	var sUser	= "USR";

	function isModeUsed(mode) {
		if (document.form.wan_modem_type.value == mode)
			return 1;
		else
			return 0;
	}

	function changeUSBConnectionType() {
		var apn_dialno = $('.sect tr').has('input[name="wan_modem_apn"], input[name="wan_modem_dialno"]');
		if (isModeUsed(sGPRS) || isModeUsed(sUser))
			apn_dialno.show();
		else
			apn_dialno.hide();
	}

	function change_autodetect_dev() {
		var frm = document.form;
		var flag = 0;
		if (get_radio_value(frm.wan_modem_autodetect) == "0")
			flag = 1;
		inputCtrl2(frm.wan_modem_usbloc, flag);
		inputCtrl2(frm.wan_modem_pdata, flag);
		inputCtrl2(frm.wan_modem_pui, flag);
		inputCtrl2(frm.wan_modem_vid, flag);
		inputCtrl2(frm.wan_modem_pid, flag);
	}

	function disable_autodetect() {
		inputRCtrl2(document.form.wan_modem_autodetect, 0);
		change_autodetect_dev();
	}

	function load_this_page() {
//		setUSBtts(document.form.wan_modem_usbloc.value);
		changeUSBConnectionType();
		change_autodetect_dev();
	}

	window.changeUSBparams = function (value) {
		//value is associated array
		var frm = document.form;
		if (value) {
			frm.wan_modem_usbloc.value = value.loc;
			frm.wan_modem_vid.value = "0x"+value.vid;
			frm.wan_modem_pid.value = "0x"+value.pid;
			frm.wan_modem_pdata.value = value.data;
			frm.wan_modem_pui.value = value.ui;
			frm.wan_modem_type.value = value.type;
			changeUSBConnectionType();
			disable_autodetect();
		}
	}
	$(document).ready(function() {
		// load_body();
		load_this_page();
	});
</script>
</head>
<body>
<form method="get" name="form" id="form" action="apply.cgi">
<input type="hidden" name="current_page" value="connectionmode.asp" />
<input type="hidden" name="next_page" value="connectionmode.asp" />
<input type="hidden" name="next_host" value="" />
<input type="hidden" name="group_id" value="" />
<input type="hidden" name="modified" value="0" />
<input type="hidden" name="action_mode" value="" />
<input type="hidden" name="first_time" value="" />
<input type="hidden" name="action_script" value="" />
<input type="hidden" name="wan_proto" value="<% nvram_get("wan_proto"); %>" />

<table class="main">
<thead>
<tr>
<td>USB Network Devices - 3G/CDMA Modem</td>
</tr>
</thead>

<tr><td>
<table class="sect">
<tr>
<td class="desc" colspan="2">The router supports following connection methods. Please select the mode that match
				your situation.</td>
</tr>
<tr>
<th>Set as WAN Connection Type by default</th>
<td nowrap><input type="checkbox" value="dhcp" name="wan_proto_x" class="content_input_fd" 
onchange="return change_common_radio(this, '3GConfig', 'wan_proto', '1')" <% nvram_match("wan_proto", "usbmodem", "checked"); %> /></td>
</tr>
<tr>
<th>Zero CD Configuration</th>
<td>
<select name="wan_modem_zerocd_mode" class="content_input_fd" onChange="return change_common(this, '3GConfig', 'wan_modem_zerocd_mode')">
<option class="content_input_fd" value="" <%nvram_match("wan_modem_zerocd_mode",  "","selected"); %>>
Not set</option>
<option class="content_input_fd" value="Auto" <%nvram_match("wan_modem_zerocd_mode", "Auto","selected"); %>>
Auto</option>
<option class="content_input_fd" value="UserDefined" <%nvram_match("wan_modem_zerocd_mode", "UserDefined","selected"); %>>
Config at /usr/local/etc/usb_modeswitch.conf</option>
</select>
</td>
</tr>
</table>
</td></tr>

<tr><td>
<table class="sect">
<thead>
<tr>
<td colspan="2">Modem options</td>
</tr>
</thead>
<tr>
<th>Modem type:</th>
<td>
<select name="wan_modem_type" class="content_input_fd" onchange="changeUSBConnectionType();window.top.pageChanged = 1;disable_autodetect();">
<option class="content_input_fd" value="W" <%nvram_match("wan_modem_type", "W","selected"); %>>
GPRS/UMTS/LTE</option>
<option class="content_input_fd" value="C" <%nvram_match("wan_modem_type",  "C","selected"); %>>
CDMA</option>
<option class="content_input_fd" value="USR" <%nvram_match("wan_modem_type", "USR","selected"); %>>
User defined</option>
</select>
</td>
</tr>
<tr>
<th>Username:</th>
<td><input type="text" maxlength="256" class="content_input_fd" size="32" name="wan_modem_username"
	value="<% nvram_get("wan_modem_username"); %>" onkeypress="return is_string(event, this)"
	onblur="validate_string(this)" /></td>
</tr>
<tr>
<th>Password:</th>
<td><input type="password" maxlength="256" class="content_input_fd" size="32" name="wan_modem_passwd"
	value="<% nvram_get("wan_modem_passwd"); %>" onkeypress="return is_string(event, this)"
	onblur="validate_string(this)" /></td>
</tr>
<tr>
<th>APN:</th>
<td><input type="text" maxlength="256" class="content_input_fd" size="32" name="wan_modem_apn"
	value="<% nvram_get("wan_modem_apn"); %>" onkeypress="return is_string(event, this)"
	onblur="validate_string(this)" /></td>
</tr>
<tr>
<th>Dial Number (usually *99***1# or *99#):</th>
<td><input type="text" maxlength="256" class="content_input_fd" size="32" name="wan_modem_dialno"
	value="<% nvram_get("wan_modem_dialno"); %>" onkeypress="return is_string(event, this)"
	onblur="validate_string(this)" /></td>
</tr>
<tr>
<th>Call on Demand</th>
<td>
<input type="radio" value="0" name="wan_modem_demand" class="content_input_fd" onClick="return change_common_radio(this, '3GConfig', 'wan_modem_demand', '0')" <% nvram_match("wan_modem_demand", "0", "checked"); %> />No
<input type="radio" value="1" name="wan_modem_demand" class="content_input_fd" onClick="return change_common_radio(this, '3GConfig', 'wan_modem_demand', '1')" <% nvram_match("wan_modem_demand", "1", "checked"); %> />Yes
</td>
</tr>
<tr>
<th title="This field allows you to configure to terminate your ISP connection after a specified period of time.">Idle time before disconnect (sec):</th>
<td><input type="text" maxlength="32" class="content_input_fd" size="32" name="wan_modem_idle"
	value="<% nvram_get("wan_modem_idle"); %>" onkeypress="return is_number(event, this)"
	onblur="validate_string(this)" /></td>
</tr>
<tr>
<th title="That is Maximum Transmission Unit(MTU) of PPP packet.">MTU</th>
<td><input type="text" maxlength="32" class="content_input_fd" size="32" name="wan_modem_mtu"
	value="<% nvram_get("wan_modem_mtu"); %>" onkeypress="return is_number(event, this)"
	onblur="validate_string(this)" /></td>
</tr>
<tr>
<th title="That is Maximum Receive Unit(MRU) of PPP packet.">MRU</th>
<td><input type="text" maxlength="32" class="content_input_fd" size="32" name="wan_modem_mru"
	value="<% nvram_get("wan_modem_mru"); %>" onkeypress="return is_number(event, this)"
	onblur="validate_string(this)" /></td>
</tr>
</table>
</td></tr>

<tr><td>
<table class="sect">
<thead>
<tr>
<td colspan="2">Custom USB device parameters</td>
</tr>
</thead>
<tr>
<th title="Detect VID:PID every time at usb-modem plugging.">Autodetect device</th>
<td nowrap>
<input type="radio" value="0" name="wan_modem_autodetect" class="content_input_fd" onClick="return change_autodetect_dev()" <% nvram_match("wan_modem_autodetect", "0", "checked"); %> />No
<input type="radio" value="1" name="wan_modem_autodetect" class="content_input_fd" onClick="return change_autodetect_dev()" <% nvram_match("wan_modem_autodetect", "1", "checked"); %> />Yes
</td>
</tr>

<tr>
<th title="Select parameters for connected USB modem"> View connected modems</th>
<td><input type="button" value="View" onClick="window.open('devpath_select_form.asp','Select_devpath','width=800,height=200,left=150,top=200,scrollbars=1')" /></td>
</tr>

<tr>
<th title="USB device location in USB tree. Press View button or see Status &amp; Log -> Diagnostic Info -> USB devfs Devices and find the ID in the second column (eg 1.1.0). If blank, use default.">USB device location ID:</th>
<td><input type="text" maxlength="256" class="content_input_fd" size="32" name="wan_modem_usbloc"
	value="<% nvram_get("wan_modem_usbloc"); %>" onkeypress="return is_string(event, this)"
	onblur="validate_string(this)" /></td>
</tr>

<tr>
<th title="This field allows you to specify data port manually. If Autodetect device option is enabled, the router will define it automatically.">Data port:</th>
<td><input type="text" maxlength="256" class="content_input_fd" size="32" name="wan_modem_pdata"
	value="<% nvram_get("wan_modem_pdata"); %>" onkeypress="return is_string(event, this)"
	onblur="validate_string(this)" /></td>
</tr>
<tr>
<th title="This field allows you to specify user interface port manually. If Autodetect device option is enabled, the router will define it automatically.">User interface port:</th>
<td><input type="text" maxlength="256" class="content_input_fd" size="32" name="wan_modem_pui"
	value="<% nvram_get("wan_modem_pui"); %>" onkeypress="return is_string(event, this)"
	onblur="validate_string(this)" /></td>
</tr>

<tr>
<th title="This field allows you to specify USB vendor ID manually. If Autodetect device option is enabled, the router will define it automatically.">USB device Vendor ID (0xabcd):</th>
<td><input type="text" maxlength="256" class="content_input_fd" size="32" name="wan_modem_vid"
	value="<% nvram_get("wan_modem_vid"); %>" onkeypress="return is_string(event, this)"
	onblur="validate_string(this)" /></td>
</tr>
<tr>
<th title="This field allows you to specify USB product ID manually. If Autodetect device option is enabled, the router will define it automatically.">USB device Product ID (0xef01):</th>
<td><input type="text" maxlength="256" class="content_input_fd" size="32" name="wan_modem_pid"
	value="<% nvram_get("wan_modem_pid"); %>" onkeypress="return is_string(event, this)"
	onblur="validate_string(this)" /></td>
</tr>

<tr>
<th>USB device serial speed (usually 921600):</th>
<td><input type="text" maxlength="256" class="content_input_fd" size="32" name="wan_modem_portspeed"
	value="<% nvram_get("wan_modem_portspeed"); %>" onkeypress="return is_number(event, this)"
	onblur="validate_range(this, 0, 921600)" /></td>
</tr>
</table>
</td></tr>

<tr><td>
<table class="sect">
<thead>
<tr>
<td colspan="2">Additional parameters</td>
</tr>
</thead>
<tr>
<th>Device initial script:</th>
<td><input type="text" maxlength="256" class="content_input_fd" size="32" name="wan_modem_init_script"
	value="<% nvram_get("wan_modem_init_script"); %>" onkeypress="return is_string(event, this)"
	onblur="validate_string(this)" /></td>
</tr>
<tr>
<th>Additional AT commands:</th>
<td><input type="text" maxlength="256" class="content_input_fd" size="32" name="wan_modem_dialup_init"
	value="<% nvram_get("wan_modem_dialup_init"); %>" onkeypress="return is_string(event, this)"
	onblur="validate_string(this)" /></td>
</tr>
<tr>
<th title="This item may be specified by some ISPs. Check with your ISP and fill them in if required.">Additional pppd options:</th>
<td><input type="text" maxlength="256" class="content_input_fd" size="32" name="wan_modem_options"
	value="<% nvram_get("wan_modem_options"); %>" onkeypress="return is_string(event, this)"
	onblur="validate_string(this)" /></td>
</tr>
<tr>
<th>Failure event script name:</th>
<td><input type="text" maxlength="256" class="content_input_fd" size="32" name="wan_modem_onfailure"
	value="<% nvram_get("wan_modem_onfailure"); %>" onkeypress="return is_string(event, this)"
	onblur="validate_string(this)" /></td>
</tr>
<tr>
<th title="If this parameter is not zero, then Failure event script will be started after max number of reconnections.">Max number of reconnections (0 for unlimit):</th>
<td><input type="text" maxlength="10" class="content_input_fd" size="32" name="wan_modem_maxfail"
	value="<% nvram_get("wan_modem_maxfail"); %>" onkeypress="return is_number(event, this)" /></td>
</tr>
<tr>
<th>Action:</th>
<td>
<input type="submit" class="content_input_button" onclick="return onSubmitApply('dhcpc_release')"
	name="PPPConnection_x_WANAction_button" value="Disconnect" />
<input type="submit" class="content_input_button" onclick="return onSubmitApply('dhcpc_renew')"
	name="PPPConnection_x_WANAction_button1" value="Connect" />
</td>
</tr>
</table>
</td></tr>

</table>

<% include("footer_buttons.inc"); %>

</form>
</body>
</html>
